<?php


class PhpClassFactory extends Base
{
    //
    // Singleton pattern
    //
    /**
     * __construct
     * 
     * @author Pablo López Torres <pablolopeztorres@gmail.com> 
     * @return void
     */
    private function __construct()
    {
        // just to assure it is not instanciated from the outside 
    }

    /**
     * instance 
     * 
     * @var PhpClassFactory
     * @access private
     */
    private static $instance;

    /**
     * getInstance
     * 
     * @author Pablo López Torres <pablolopeztorres@gmail.com> 
     * @return PhpClassFactory
     */
    public static function getInstance()
    {
        if (! isset(self::$instance))
        {
            self::$instance = new self();
        }

        return self::$instance;
    }


	/**
	 * load
	 * 
	 * @access public
	 * @author Pablo López Torres <pablolopeztorres@gmail.com> 
	 * @param mixed $projectName 
	 * @param mixed $className 
	 * @return void
	 */
	public function load($projectName, $className)
	{
		$persistentKey = $this->getPersistentKey($projectName, $className);
		return Storage::load($persistentKey);
	}

	/**
	 * getPersistentKey
	 * 
	 * @access public
	 * @author Pablo López Torres <pablolopeztorres@gmail.com> 
	 * @param mixed $projectName 
	 * @param mixed $className 
	 * @return void
	 */
	public function getPersistentKey($projectName, $className)
	{
		return $projectName . '/class_' . $className;
	}
}

